import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;

public class Love {
//    private static int[] x = {-1,0,0,1};
//    private static int[] y = {0,-1,1,0};
//    private static int max = 0;
//    private static int path = 0;
//    private static int length;
//    private static int minlength = 0x3f3f3f3f;
//    private static Map<Character, Integer> map = new HashMap<>();
//    private static boolean[][] vis;
//    public static void main(String[] args) {
//        Scanner in = new Scanner(System.in);
//        // 注意 hasNext 和 hasNextLine 的区别
//        int m = in.nextInt();
//        int n = in.nextInt();
//        map.put('l', 4);
//        map.put('o', 3);
//        map.put('v', 2);
//        map.put('e', 1);
//        char[][] grid = new char[m][n];
//        vis = new boolean[m][n];
//        in.nextLine();
//        for (int i = 0; i < m; i++) {
//            String s = in.nextLine();
//            char[] c = s.toCharArray();
//            for (int j = 0; j < n; j++) {
//                grid[i][j] = c[j];
//            }
//        }
//        vis[0][0] = true;
//        path += map.getOrDefault(grid[0][0], 0);
//        dfs(grid, 0, 0);
//        System.out.println(max);
//    }
//
//    private static void dfs(char[][] grid, int row, int col) {
//        if (row == grid.length-1 && col == grid[0].length-1
//                && (minlength == 0x3f3f3f3f || length == minlength)) {
//            max = Math.max(max, path);
//            minlength = Math.min(minlength, length);
//            return;
//        }
//        for (int i = 0; i < 4; i++) {
//            int newRow = row + x[i];
//            int newCol = col + y[i];
//            if (newRow >= 0 && newRow < grid.length
//                    && newCol >= 0 && newCol < grid[0].length
//                    && !vis[newRow][newCol]) {
//                length++;
//                vis[newRow][newCol] = true;
//                path += map.getOrDefault(grid[newRow][newCol], 0);
//                dfs(grid, newRow, newCol);
//                length--;
//                path -= map.getOrDefault(grid[newRow][newCol], 0);
//                vis[newRow][newCol] = false;
//            }
//        }
//    }

    private static int[] x = {-1, 0, 0, 1};
    private static int[] y = {0, -1, 1, 0};
    private static int max;
    private static int path;
    private static int length;
    private static int minlength = 0x3f3f3f3f;
    private static Map<Character, Integer> map = new HashMap<>();
    private static boolean[][] vis;
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        // 注意 hasNext 和 hasNextLine 的区别
        map.put('l', 4);
        map.put('o', 3);
        map.put('v', 2);
        map.put('e', 1);
        while (in.hasNext()) {
            max = 0;
            path = 0;
            length = 0;
            minlength = 0x3f3f3f3f;
            int m = in.nextInt();
            int n = in.nextInt();
            char[][] grid = new char[m][n];
            vis = new boolean[m][n];
            in.nextLine();
            for (int i = 0; i < m; i++) {
                String s = in.nextLine();
                char[] c = s.toCharArray();
                for (int j = 0; j < n; j++) {
                    grid[i][j] = c[j];
                }
            }
            vis[0][0] = true;
            path += map.getOrDefault(grid[0][0], 0);
            dfs(grid, 0, 0);
            System.out.println(max);
        }
    }

    private static void dfs(char[][] grid, int row, int col) {
        if (row == grid.length - 1 && col == grid[0].length - 1
                && (minlength == 0x3f3f3f3f || length <= minlength)) {
            max = Math.max(max, path);
            minlength = Math.min(minlength, length);
            return;
        }
        for (int i = 0; i < 4; i++) {
            int newRow = row + x[i];
            int newCol = col + y[i];
            if (newRow >= 0 && newRow < grid.length
                    && newCol >= 0 && newCol < grid[0].length
                    && !vis[newRow][newCol]) {
                length++;
                vis[newRow][newCol] = true;
                path += map.getOrDefault(grid[newRow][newCol], 0);
                dfs(grid, newRow, newCol);
                length--;
                path -= map.getOrDefault(grid[newRow][newCol], 0);
                vis[newRow][newCol] = false;
            }
        }
    }
}
